﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.popups.missions {
    import reprise.ui.*;
    import flash.events.*;
    import flash.display.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.world.vos.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;

    public class MissionRewardPopupMediator extends AbstractMissionPopupMediator {

        override protected function setContent():void{
            var _local5:TaskVO;
            var _local1:UIComponent = RepriseUtils.addComponent(this.view, "rewardContent");
            addLabel("rewardHeader myriadProFontOutline", "levelup_youget", null, _local1);
            addLabel("rewardCoins myriadProFont", "mission_reward_type1", {amount:_mission.coins}, _local1);
            addLabel("rewardXp myriadProFont", "mission_reward_type2", {amount:_mission.xp}, _local1);
            var _local2:String = (_mission.isSolved) ? "global_button_share" : "global_button_ok";
            setOkButton(_local2);
            var _local3:UIComponent = RepriseUtils.addComponent(_local1, "missionContainer");
            var _local4 = 1;
            for each (_local5 in _mission.tasks) {
                var _temp1 = _local4;
                _local4 = (_local4 + 1);
                this.setTask(_temp1, _local5, _local3);
            };
            dispatch(new InfoEvent(EventConstants.PLAY_EFFECT_SOUND, GameConstants.SOUND_HARVEST));
        }
        private function setTask(_arg1:int, _arg2:TaskVO, _arg3:UIComponent):void{
            var num = _arg1;
            var task = _arg2;
            var cont = _arg3;
            var taskContainer:UIComponent = RepriseUtils.addComponent(cont, "missionTask");
            var thumb:String = getTaskThumb(task);
            var iconClip:MovieClip = getTaskIcon(thumb);
            var iconHolder:MovieClip = AssetsLibrary.getMovieClip("TaskIconHolder");
            if (iconClip){
                iconClip.gotoAndStop("default");
                iconHolder.icon.addChild(iconClip);
                Displays.correctScaling(iconHolder.icon, iconClip, 50, 50);
            };
            var icon:UIComponent = RepriseUtils.addClipComponent(taskContainer, "taskIcon", iconHolder);
            var taskKey = (((("mission_" + _mission.code) + "_task") + num) + "_");
            var petName:String = getPetName(task.type);
            var text:String = language.getTextByKey((taskKey + "title"), {amount:task.required, pet:petName});
            RepriseUtils.addLabel(taskContainer, "miniTaskLabel myriadProFontOutline", text);
            Displays.correctScaling(icon, iconHolder, 30, 30);
            var solvedClip:MovieClip = AssetsLibrary.getMovieClip("SolvedIcon");
            var solvedIcon:UIComponent = RepriseUtils.addClipComponent(taskContainer, "solvedIcon", solvedClip);
            RepriseUtils.validateComponent(solvedIcon, function (_arg1:ClipComponent):void{
                Displays.correctScaling(_arg1, _arg1.clip, _arg1.width, _arg1.height, -1, -1);
            });
        }
        private function get view():MissionRewardPopupView{
            return ((viewComponent as MissionRewardPopupView));
        }
        override protected function onOk(_arg1:MouseEvent):void{
            dispatch(new InfoEvent(EventConstants.POST_ON_WALL, null, {type:GameConstants.MISSION_SOLVED, code:_mission.code}));
            super.onOk(_arg1);
        }

    }
}//package net.wooga.pets.views.popups.missions 
